package xrz.cuanbao.adapters;

import org.xutils.x;
import org.xutils.common.Callback.CancelledException;
import org.xutils.common.Callback.CommonCallback;

import com.xrz.sxm.base.utils.ScreenUtil;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.widget.ImageView;
import android.widget.LinearLayout.LayoutParams;
import joanzapata.android.BaseAdapterHelper;
import joanzapata.android.QuickAdapter;
import xrz.cuanbao.R;
import xrz.cuanbao.entitys.MyDaiyan;

public class Adapter_daiyan extends QuickAdapter<MyDaiyan> {

	public Adapter_daiyan(Context context, int layoutResId) {
		super(context, layoutResId);
	}

	@Override
	protected void convert(BaseAdapterHelper arg0, MyDaiyan arg1) {
		final ImageView img = arg0.getView(R.id.img);
		arg0.setText(R.id.tv_title, arg1.title);

		x.image().bind(img, arg1.thumb, new CommonCallback<Drawable>() {

			@Override
			public void onSuccess(Drawable arg0) {
				LayoutParams layoutParams = (LayoutParams) img.getLayoutParams();
				int width = ScreenUtil.getInstant().getDisWidth(context) / 4;
				int hight = width + 50;
				layoutParams.width = width;
				layoutParams.height = hight;
				img.setLayoutParams(layoutParams);
			}

			@Override
			public void onFinished() {
				// TODO Auto-generated method stub

			}

			@Override
			public void onError(Throwable arg0, boolean arg1) {
				// TODO Auto-generated method stub

			}

			@Override
			public void onCancelled(CancelledException arg0) {
				// TODO Auto-generated method stub

			}
		});
	}

}
